package jee.boot.common.rest;

import jee.boot.common.basic.TreeController;
import jee.boot.common.basic.result.ResponseMessage;
import jee.boot.common.basic.result.Result;
import jee.boot.common.service.DictionaryService;
import jee.boot.entity.system.Dictionary;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统字典
 */
@RestController
@RequestMapping(value = "/dictionary")
public class DictionaryRestController extends TreeController<DictionaryService, Dictionary> {
    /**
     * 列表
     *
     * @param entity
     * @return
     */
    @PostMapping("/initCache")
    public ResponseMessage<Dictionary> initCache(@RequestBody Dictionary entity) {
        service.initCache(entity);
        logger.debug("缓存字典主数据");
        return Result.success();
    }
    /**
     * 列表
     *
     * @param entity
     * @return
     */
    @PostMapping("/typeList")
    public ResponseMessage<List<Dictionary>> typeList(@RequestBody Dictionary entity) {
        List<Dictionary> typeList = service.findTypeList(entity);
        return Result.success(typeList);
    }

}